export default function(content, questionAnsSort, type) {
    if (!questionAnsSort) {
        return content;
    }
    console.log("type", type);
    switch (type) {
        case "TypeA1":
            return SingleChoice(content);
            break;
        case "TypeA2":
            return SingleChoice(content);
            break;
        case "TypeA3":
            return SingleChoiceList(content);
            break;
        case "TypeA4":
            return SingleChoiceList(content);
            break;
        case "TypeB1":
            return MultipleStem(content);
            break;
        case "TypeM1":
            return SingleChoiceList(content);
            break;
        case "TypeSingleChoice":
            return SingleChoice(content);
            break;
        case "TypeMultipleChoice":
            return MultipleChoice(content);
            break;
        case "TypeJudge":
            return Judge(content);
            break;
        case "TypeSort":
            return Sort(content);
            break;
        case "TypeEssay":
            return Essay(content);
            break;
        case "TypeFlow":
            return Flow(content);
            break;
        case "TypeWork":
            return Work(content);
            break;
        case "TypeSubjective":
            return Work(content);
            break;
        case "TypeExplanation":
            return Work(content);
            break;
        default:
            break;
    }
}
function SingleChoice(content) {
    content.choiceAndAnswerList = random(content.choiceAndAnswerList);
    return content;
}

function SingleChoiceList(content) {
    content.questionList.forEach((questionList, index) => {
        questionList.questionList.forEach((question, idx) => {
            question.choiceAndAnswerList = random(question.choiceAndAnswerList);
        });
    });
    return content;
}
function MultipleStem(content) {
    content.questionList.forEach((question, idx) => {
        question.choiceAndAnswerList = random(question.choiceAndAnswerList);
    });
    return content;
}

function MultipleChoice(content) {
    content.choiceAndAnswerList = random(content.choiceAndAnswerList);
    return content;
}
function Judge(content) {
    return content;
}
function Sort(content) {
    content.sortList = random(content.sortList);
    return content;
}
function Essay(content) {
    return content;
}
function Flow(content) {
    content.questionList.forEach((question, index) => {
        question.choiceAndAnswerList = random(question.choiceAndAnswerList);
    });
    return content;
}
function Work(content) {
    return content;
}
function random(arr) {
    arr.sort(function() {
        return 0.5 - Math.random();
    });
    return arr;
}
